//
//  main.m
//  03应用程序启动原理
//
//  Created by J on 16/1/18.
//  Copyright © 2016年 J. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

//main程序的入口
int main(int argc, char * argv[]) {
    @autoreleasepool {//非arc
        
        //The name of the UIApplication class or subclass. If you specify nil, UIApplication is assumed.
        
        NSLog(@"%@", NSStringFromClass([AppDelegate class]));
        //类名转字符串好处:1.防止输入错误
        //字符串转类名
//        NSClassFromString(@"AppDelegate");
        ///
        ///
        ///  @param argc
        ///  @param argv
        ///  @param nil    UIApplication
        ///  @param class] AppDelegate类名转换为字符串 必须要遵守UIApplicationDelegate协议
        ///
        ///  @return <#return value description#>
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

/*UIApplicationMain底层实现
1.根据principalClassName创建UIApplication对象
2.创建UIApplicationDelegate对象 并且成为UIApplication 对象代理 app.appdelegata = delegate
3.开启一个主运行循环,处理事件 可以保持程序一直运行
 4.加载Info.plist 并且判断有没有指定main.storyboard 如果指定了,就会去加载
 
//Discussion
//This function instantiates the application object from the principal class and instantiates the delegate (if any) from the given class and sets the delegate for the application. It also sets up the main event loop, including the application’s run loop, and begins processing events. If the application’s Info.plist file specifies a main nib file to be loaded, by including the NSMainNibFile key and a valid nib file name for the value, this function loads that nib file.

 */

